import unittest
from alg import Solution
from gen import generate_test_cases


class TestSolution(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test_example_cases(self):
        """测试示例和边界用例"""
        test_cases = generate_test_cases(num_cases=0)  # 仅使用手动用例
        for case in test_cases:
            g = case["g"]
            s = case["s"]
            expected = case["expected"]
            with self.subTest(g=g, s=s, expected=expected):
                self.assertEqual(self.solution.findContentChildren(g, s), expected)

    def test_random_cases(self):
        """测试随机生成的用例"""
        test_cases = generate_test_cases(num_cases=10)  # 生成10个随机用例
        for case in test_cases:
            g = case["g"]
            s = case["s"]
            expected = case["expected"]
            with self.subTest(g=g, s=s, expected=expected):
                self.assertEqual(self.solution.findContentChildren(g, s), expected)


if __name__ == "__main__":
    unittest.main()